//
//  UserManager.m
//  aiteshangcheng
//
//  Created by 艾特—iOS on 16/4/12.
//  Copyright © 2016年 aite. All rights reserved.
//

#import "UserManager.h"

@implementation UserManager

+ (instancetype)shareUser
{
    static UserManager *instance = nil;
    if (instance == nil) {
        instance = [[UserManager alloc] init];
        // 1.获得沙盒根路径
        NSString *home = NSHomeDirectory();
        
        // 2.document路径
        NSString *docPath = [home stringByAppendingPathComponent:@"Documents"];
        NSString *filepath = [docPath stringByAppendingPathComponent:@"key.plist"];
        
        BOOL blHave = [[NSFileManager defaultManager] fileExistsAtPath:filepath];
        
        if (blHave) {
            NSDictionary *keydic = [NSDictionary dictionaryWithContentsOfFile:filepath];
            
            instance.key = [keydic objectForKey:@"key"];
            
            
            // 获取用户名
            NSString *filepathName = [docPath stringByAppendingPathComponent:@"userAndpassword.plist"];
            NSDictionary *dicName = [NSDictionary dictionaryWithContentsOfFile:filepathName];
            instance.username = [dicName objectForKey:@"username"];
        }
        

    }
    return instance;
}

@end
